//
//  ZZTaskMaxMinEditVC.swift
//  QMXK
//
//  Created by jenkin on 2018/12/10.
//  Copyright © 2018年 jenkin. All rights reserved.
//

import UIKit
import SnapKit

typealias SaveBlock = (_ data:Dictionary<String, Any>) -> Void

class ZZTaskMaxMinEditVC: ZZBaseVC {

    var maxTextField:UITextField!
    var minTextField:UITextField!
    var saveBlock:SaveBlock!
    override func viewDidLoad() {
        super.viewDidLoad()
        self.setUI()
    }
    
    override func setUI(){
        super.setUI()
        self.maxTextField = UITextField.init(frame: CGRect.init())
        self.maxTextField.backgroundColor = UIColor.white
        self.maxTextField.placeholder = "最大值输入"
        self.maxTextField.keyboardType = UIKeyboardType.numbersAndPunctuation
        self.view.addSubview(self.maxTextField)
        self.maxTextField.snp.makeConstraints { (make) in
            make.centerX.equalTo(self.view)
            make.top.equalTo(100)
            make.height.equalTo(30)
            make.width.equalTo(100)
        }
        
        self.minTextField = UITextField.init(frame: CGRect.init())
        self.minTextField.placeholder = "最小值输"
        self.minTextField.backgroundColor = UIColor.white
        self.minTextField.keyboardType = UIKeyboardType.numbersAndPunctuation
        self.view.addSubview(self.minTextField)
        self.minTextField.snp.makeConstraints { (make) in
            make.centerX.equalTo(self.view)
            make.top.equalTo(self.maxTextField.snp.bottom).offset(30)
            make.height.equalTo(30)
            make.width.equalTo(100)
        }
        
        let sureBtn:UIButton = UIButton.init()
        sureBtn.setTitle("确定", for: UIControl.State.normal)
        sureBtn.addTarget(self, action: #selector(sureAction(sender:)), for: UIControl.Event.touchUpInside)
        sureBtn.backgroundColor = ColorConst.shareColorConst.mainTintColor()
        self.view.addSubview(sureBtn)
        sureBtn.snp.makeConstraints { (make) in
            make.centerX.equalTo(self.view)
            make.width.equalTo(100)
            make.height.equalTo(30)
            make.top.equalTo(self.minTextField.snp.bottom).offset(30)
        }
    }
    
    @objc func sureAction(sender:UIButton){
        var dict:Dictionary<String, Any>! = Dictionary.init()
        dict["allMax"] = ZZBaseUtil.shareUtil.getFloatWihDatStr(text: self.maxTextField.text!)
        dict["allMin"] = ZZBaseUtil.shareUtil.getFloatWihDatStr(text: self.minTextField.text!)
        if self.saveBlock != nil{
            self.saveBlock(dict)
            self.navigationController?.popViewController(animated: true)
        }
    }
}
